<!DOCTYPE html>
<html lang="zh-CN">

	<head>
		<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta http-equiv="Cache-Control" content="no-cache, must-revalidate">
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta name="renderer" content="webkit">
		<title>GT pro pro登录</title>
		<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
		<link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.min.css">
		<link rel="stylesheet" href="bower_components/Ionicons/css/ionicons.min.css">
		<link rel="stylesheet" href="bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css">
		<link rel="stylesheet" href="dist/css/AdminLTE.min.css">
		<link rel="stylesheet" href="dist/css/skins/skin-blue.min.css">
		<link rel="stylesheet" href="css/style.css">
		<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
		<link rel="icon" href="img/logo.ico" type="image/x-icon" />
		<link rel="stylesheet" href="./css/clear.css" />
		<link rel="stylesheet" href="./css/login.css" />
		<style>
			.codeBox{
				position: relative;
			}
			#picCode{
				position: absolute;
				right: 6px;
				top: 6px;
			}
		</style>
	</head>
	<body class="login">
		<div class="loginBox">
			<div class="loginTit">
				<h3>GT <sup>pro</sup> 商户后台</h3>
			</div>
			<div class="userName inputBox">
				<input type="text" placeholder="请输入用户名" id="account" />
			</div>
			<div class="password inputBox">
				<input type="password" placeholder="请输入6位数以上的密码" id="password" />
			</div>
			<div class="password inputBox codeBox">
				<input type="text" placeholder="输入图形验证码" maxlength="6" id="picCodeValue" />
				<div class="imgCode" id="picCode"></div>
			</div>
			<input type='button' value="登 录" />
		</div>
		<div class="modal fade" id="modal-default">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-label="Close">
                  <span aria-hidden="true">&times;</span></button>
						<h4 class="modal-title">登录确认</h4>
					</div>
					<div class="modal-body">
						<form role="form">
							<div class="box-body">
								<div class="form-group">
									<input type="code" class="form-control" id="model-code" placeholder="请输入短信验证码">
									<input type="hidden" class="" id="code_token">
								</div>
							</div>
							<!-- /.box-body -->
						</form>
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-default pull-left" data-dismiss="modal">关闭</button>
						<button type="button" class="btn btn-primary" id="model-next">继续登录</button>
					</div>
				</div>
			</div>
		</div>
		<script src="bower_components/jquery/dist/jquery.min.js"></script>
		<script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
		<script src="bower_components/datatables.net/js/jquery.dataTables.min.js"></script>
		<script src="bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>

		<script src="bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"></script>

		<script src="dist/js/adminlte.min.js"></script>
		<script type="text/javascript" src="js/argument.js"></script>
		<script type="text/javascript">
			function getPicCode(account){
				$.ajax({	
					type: "post",
					url: url + "BackGetPicCode",
					async: true,
					data: {
						data:JSON.stringify({account:account})
					},
					contentType:'application/x-www-form-urlencoded',
					dataType: "json",
					success: function(res) {
						if(res.status == 1) {
							var resJSON = res.data.pic_code;
							$("#picCode").html('<img src="data:image/png;base64,'+resJSON+'">')
						} else {
							alert(res.error)
						}
					}
				})
			}
			$("#account").change(function(){
				var account = $(this).val();
				getPicCode(account)
			})
			
			$("#picCode").click(function(){
				var account = $("#account").val();
				getPicCode(account)
			})
			$("input[type=button]").click(function() {
				var account = $("#account").val(),
					password = $("#password").val(),
					pic_code = $("#picCodeValue").val();
				var data = {
					account,
					password,
					pic_code
				}
				$.ajax({	
					type: "post",
					url: url + "ManagerLogin",
					async: true,
					data: {
						data:JSON.stringify(data)
					},
					contentType:'application/x-www-form-urlencoded',
					dataType: "json",
					success: function(res) {
						if(res.status == 1) {
							var resJSON = res.data;
							localStorage.setItem("wallet_name", resJSON.base_info.account);
							localStorage.setItem("wallet_token", resJSON.token);
							localStorage.setItem("wallet_menu", JSON.stringify(resJSON.auth_list));
							for(var i = 0; i < resJSON.auth_list.length; i++) {
								if(resJSON.auth_list[i].web_url) {
									window.location.href = resJSON.auth_list[i].web_url;
									return false;
								}
							}
						} else if(res.status == 21) {
							$("#code_token").val(res.data.code_token);
							$('#modal-default').modal('show');
						} else {
							alert(res.error)
						}
					}
				})
			})
			
			$("#model-next").click(function() {
				$('#modal-default').modal('hide');
				var data = {
					code_token:$("#code_token").val(),
					phone_code: $("#model-code").val()//
				}
				$.ajax({
					type: "post",
					url: url + "ManagerLoginCheckCode",
					async: true,
					contentType: "application/x-www-form-urlencoded",
					data: {data:JSON.stringify( data )},
					dataType: "json",
					success: function(res) {
						if(res.status == 1) {
							var resJSON = res.data;
							localStorage.setItem("wallet_name", resJSON.base_info.account);
							localStorage.setItem("wallet_token", resJSON.token);
							localStorage.setItem("wallet_menu", JSON.stringify(resJSON.auth_list));
							for(var i = 0; i < resJSON.auth_list.length; i++) {
								if(resJSON.auth_list[i].web_url) {
									window.location.href = resJSON.auth_list[i].web_url;
									return false;
								}
							}
						} else {
							alert(res.error);
						}
					}
				})
			})
		</script>
	</body>

</html>